Control Statements
A
control statement
is statement that controls when and how other statements are executed. Most control statements are compound statements--that is, statements that contain other statements.
By default, AppleScript executes the statements in a script in sequence, one after the other. Control statements can change the order in which AppleScript executes statements by causing AppleScript to repeat or skip statements or go to a different statement.
The first two sections in this chapter provide general information on working with control statements:
The rest of the chapter describes the following AppleScript control statements:
-
Tell Statements
define the default target to which commands are sent if no direct object is specified.
-
If Statements
allow you to execute or skip statements based on the outcome of one or more tests.
-
Repeat Statements
allow you to repeat a series of statements.
-
Try Statements
allow you to handle error messages.
-
Considering and Ignoring Statements
allow you to consider or ignore certain attributes, such as case, punctuation, and white space, in string comparisons.
-
With Timeout Statements
allow you to specify how long AppleScript waits for an application command or scripting addition to complete before stopping execution of the script and returning an error.
-
With Transaction Statements
allow you to take advantage of applications that support the notion of a transaction--a sequence of related events that should be performed as if they were a single operation.
Table A-4
summarizes the syntax for the control statements that are described in this chapter.
© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)